const path = require("path");
//css 提取
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
    //javascript 执行入口文件
    entry: './main.js',
    output: {
        //将所有依赖的模块合并输出到一个bundle.js中
        filename: 'bundle.js',
        //将文件输出到dist目录下
        path: path.resolve(__dirname,'./dist'),
    },
    module: {
        rules:[{
            // test: /\.css/,
            // use:[
            //     "style-loader",
            // {
            //     loader:'css-loader',
            //     options: {
            //         importLoaders:1,
            //         minimize:true,
            //     }
            // }]
            test: /\.css$/,
            use: [{
                loader: MiniCssExtractPlugin.loader,
                options: {
                  // you can specify a publicPath here
                  // by default it uses publicPath in webpackOptions.output
                  publicPath: '../',
                },
              },'css-loader']
        }]
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: `[name]_[contenthash:8].css`,
            chunkFilename: '[id].css',
            ignoreOrder: false,
        })
    ]
};